package packethandler;

import guild.GuildFuntion;
import io.ClientSession;
import io.OperationResponse;
import io.Packet;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import protocol.OpCode;

public class GuildPacketHandler extends PhotonHandlerBase
{

	protected static final Logger log = LoggerFactory
			.getLogger(GuildPacketHandler.class);

	protected int[] opcodes = { OpCode.GuildCreate, OpCode.GuildAdd,
			OpCode.GetGuildAll, OpCode.GetGuild, OpCode.GuildPlayerRemove,
			OpCode.GuildBuild, OpCode.GuildFund, OpCode.GuildPlayerPurview,
			OpCode.GuildInviteAdd, OpCode.GuildRemove, OpCode.GuildStopTalk,
			OpCode.GuildLevelUp, OpCode.SetGuildNotice, OpCode.SetGuildDeclaration, 
			OpCode.GetGuildNotice, OpCode.GetGuildDeclaration,OpCode.GuildDismiss,};

	public GuildPacketHandler()
	{
		HandlerDispatchManager.register(HandlerDispatch.PLAYER, opcodes, this);
	}

	@Override
	protected void OnOperationResponse(Object obj,
			ClientSession session)
	{
		OperationResponse operationResponse =  (OperationResponse)obj;
		switch (operationResponse.OperationCode)
		{
			case OpCode.GuildCreate:
				GuildFuntion.GuildCreate(operationResponse,session);
				break;
			case OpCode.GuildAdd:
				GuildFuntion.OpGuildAdd(operationResponse, session);
				break;
			case OpCode.GetGuildAll:
				GuildFuntion.GetGuildAll(operationResponse,session);
				break;
			case OpCode.GuildPlayerPurview:
				GuildFuntion.GuildPlayerPurview(operationResponse, session);
				break;
			case OpCode.GetGuild:
				GuildFuntion.GetGuild(operationResponse, session);
				break;
			case OpCode.GuildBuild:
				GuildFuntion.GuildBuild(operationResponse, session);
				break;
			case OpCode.GuildFund:
				GuildFuntion.GuildFund(operationResponse, session);
				break;
			case OpCode.GuildInviteAdd:
				GuildFuntion.GuildInviteAdd(operationResponse, session);
				break;
			case OpCode.GuildRemove:
				GuildFuntion.GuildRemove(operationResponse, session);
				break;
			case OpCode.GuildStopTalk:
				GuildFuntion.GuildStopTalk(operationResponse, session);
				break;
			case OpCode.GuildLevelUp:
				GuildFuntion.GuildLevelUpFun(operationResponse, session);
				break;
			case OpCode.GuildDismiss:
				GuildFuntion.GuildDismiss(operationResponse, session);
				break;
		}
	}

	@Override
	protected void OnHandle(Packet packet, ClientSession session)
	{
		Short opcode=packet.getOpCode();
		switch(opcode)
		{
			case OpCode.SetGuildNotice:
				GuildFuntion.SetGuildNotice(packet, session);
				break;
			case OpCode.SetGuildDeclaration:
				GuildFuntion.SetGuildDeclaration(packet, session);
				break;
			case OpCode.GetGuildNotice:
				GuildFuntion.GetGuildNotice(packet, session);
				break;
			case OpCode.GetGuildDeclaration:
				GuildFuntion.GetGuildDeclaration(packet, session);
				break;
		}
		

	}


}
